package com.zzptc.zzsgz;

import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.StringTokenizer;
import java.util.stream.Stream;

public class Test {


    public static void main(String[] args) {
        String s="aaa,bbb,ccc";
        //方式一
        StringTokenizer stringTokenizer=new StringTokenizer(s,",");
        while (stringTokenizer.hasMoreElements()){
            System.out.println(stringTokenizer.nextToken());
        }
        //方式二
        String[] strings = s.split(",");
        System.out.println(strings[0]);
        System.out.println(strings[1]);
        System.out.println(strings[2]);

       List<String> alllist=Arrays.asList("admin","red","yellow","green");
       //传统方式
       for(String s1:alllist){
           System.out.println(s1+"-------");
       }
       //lambda写法
      alllist.forEach(x-> System.out.println(x));

        try {
            ServerSocket serverSocket=new ServerSocket(9999);
            new Thread(new Runnable() {
                @Override
                public void run() {
                    while (true) {
                        try {
                            Socket socket = serverSocket.accept();
                        } catch (IOException e) {
                            e.printStackTrace();
                        }
                    }
                }
            }).start();


        } catch (IOException e) {
            e.printStackTrace();
        }


    }
}
